using System;
using System.Collections.Generic;
using System.Text;

namespace Bbq.Gallery
{
    /// <summary>
    /// 
    /// </summary>
    [Serializable]
    public class GalleryItem : ICloneable
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="GalleryItem"/> class.
        /// </summary>
        public GalleryItem()
        {

        }

        /// <summary>
        /// Initializes a new instance of the <see cref="GalleryItem"/> class.
        /// </summary>
        /// <param name="name">The name.</param>
        public GalleryItem(string name)
        {
            this._name = name;
        }

        private int _id;
        /// <summary>
        /// Gets or sets the ID.
        /// </summary>
        /// <value>The ID.</value>
        public int ID
        {
            get { return _id; }
            set { _id = value; }
        }

        private string _name;
        /// <summary>
        /// Gets or sets the name.
        /// </summary>
        /// <value>The name.</value>
        public string Name
        {
            get { return _name ?? string.Empty; }
            set { _name = value; }
        }

        private DateTime _createdDate;
        /// <summary>
        /// Gets or sets the created date.
        /// </summary>
        /// <value>The created date.</value>
        public DateTime CreatedDate
        {
            get { return _createdDate; }
            set { _createdDate = value; }
        }

        private DateTime _lastModifiedDate;
        /// <summary>
        /// Gets or sets the last modifed date.
        /// </summary>
        /// <value>The last modifed date.</value>
        public DateTime LastModifedDate
        {
            get { return _lastModifiedDate; }
            set { _lastModifiedDate = value; }
        }

        private int _totalVote;
        /// <summary>
        /// Gets or sets the total vote.
        /// </summary>
        /// <value>The total vote.</value>
        public int TotalVote
        {
            get { return _totalVote; }
            set { _totalVote = value; }
        }

        private int _voteCount;
        /// <summary>
        /// Gets or sets the vote count.
        /// </summary>
        /// <value>The vote count.</value>
        public int VoteCount
        {
            get { return _voteCount; }
            set { _voteCount = value; }
        }

        /// <summary>
        /// Gets the vote.
        /// </summary>
        /// <value>The vote.</value>
        public float Vote
        {
            get
            {
                if (this.TotalVote == 0) return 0;
                else return this.VoteCount / this.TotalVote;
            }
        }

        private GalleryItemType _type;
        /// <summary>
        /// Gets or sets the type.
        /// </summary>
        /// <value>The type.</value>
        public GalleryItemType Type
        {
            get { return _type; }
            set { _type = value; }
        }

        private string _description;
        /// <summary>
        /// Gets or sets the description.
        /// </summary>
        /// <value>The description.</value>
        public string Description
        {
            get { return _description ?? string.Empty; }
            set { _description = value; }
        }

        private int _authorID;
        /// <summary>
        /// Gets or sets the author ID.
        /// </summary>
        /// <value>The author ID.</value>
        public int AuthorID
        {
            get { return _authorID; }
            set { _authorID = value; }
        }

        private string _authorName;
        /// <summary>
        /// Gets or sets the name of the author.
        /// </summary>
        /// <value>The name of the author.</value>
        public string AuthorName
        {
            get { return _authorName ?? string.Empty; }
            set { _authorName = value; }
        }

        private int _size;

        /// <summary>
        /// Gets or sets the size.
        /// </summary>
        /// <value>The size.</value>
        public int Size
        {
            get { return _size; }
            set { _size = value; }
        }


        private int _viewCount;
        /// <summary>
        /// Gets or sets the view count.
        /// </summary>
        /// <value>The view count.</value>
        public int ViewCount
        {
            get { return _viewCount; }
            set { _viewCount = value; }
        }

        private string _pathFromRoot;
        /// <summary>
        /// Gets or sets the path from root.
        /// </summary>
        /// <value>The path from root.</value>
        public string PathFromRoot
        {
            get { return _pathFromRoot; }
            set { _pathFromRoot = value; }
        }

        /// <summary>
        /// Gets or sets the URL. Support for UrlPhysicalStorageGalleryProvider provider.
        /// </summary>
        /// <value>The URL.</value>
        internal string Url
        {
            get;
            set;
        }

        /// <summary>
        /// Gets or sets the thumbnail URL. Support for UrlPhysicalStorageGalleryProvider provider.
        /// </summary>
        /// <value>The thumbnail URL.</value>
        internal string ThumbnailUrl
        {
            get;
            set;
        }

        private bool _isExternal = false;
        /// <summary>
        /// Gets or sets a value indicating whether this instance is external.
        /// </summary>
        /// <value>
        /// 	<c>true</c> if this instance is external; otherwise, <c>false</c>.
        /// </value>
        public bool IsExternal
        {
            get { return _isExternal; }
            set { _isExternal = value; }
        }

		#region ICloneable Members

		/// <summary>
		/// Creates a new object that is a copy of the current instance.
		/// </summary>
		/// <returns>
		/// A new object that is a copy of this instance.
		/// </returns>
		public object Clone()
		{
            GalleryItem item = new GalleryItem(this._name);
            item._authorID = this._authorID;
            item._authorName = this._authorName;
            item._createdDate = this._createdDate;
            item._description = this._description;
            item._id = this._id;
            item._lastModifiedDate = this._lastModifiedDate;
            item._name = this._name;
            item._pathFromRoot = this._pathFromRoot;
            item._size = this._size;
            item._totalVote = this._totalVote;
            item._type = this._type;
            item._viewCount = this._viewCount;
            item._voteCount = this._voteCount;
            item._isExternal = this._isExternal;
            item.Url = this.Url;
            return item;
		}

		#endregion
	}

    /// <summary>
    /// 
    /// </summary>
    public enum GalleryItemType : byte
    {
        /// <summary>
        /// Can use IMG tag to display
        /// </summary>
        Picture,
        /// <summary>
        /// Should use EMBED tag to display
        /// </summary>
        Media,
        /// <summary>
        /// Should display using Windows Media Player
        /// </summary>
        CompatibleMediaPlayer,
        /// <summary>
        /// Should display using Real Player
        /// </summary>
        CompatibleRealPlayer,
        /// <summary>
        /// Should display using Quick Time
        /// </summary>
        CompatibleQuickTime,
        /// <summary>
        /// Should display using Flash Player
        /// </summary>
        CompatibleFlash,
        /// <summary>
        /// Should display as downloadable item
        /// </summary>
        Archives
    }
}
